#include <fstream>
#include <iostream>
#include <string>

using namespace std;
 
int main()
{
    string filename = "example.123";
 
    fstream fs;
    fs.open(filename);

    if (!fs.is_open())
    {
        fs.clear();
        fs.open(filename, ios::out); // create file
        fs.close();
        fs.open(filename);
    }
 
    cout << boolalpha;
    cout << "fs.is_open() = " << fs.is_open() << '\n';
    cout << "fs.good() = " << fs.good() << '\n';

    bool is_cool = true;
    cout << is_cool << endl;
}